home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscTabMatrixPalette / MiscTabActionCell.subproj / drawTab.psw next >
Text File  |  1995-02-03  |  2KB  |  74 lines

  1. /* $Id$ */
  2.  
  3. /*
  4.  * Draws the beginning (left) edge of the tab.  y coordinate is flipped.
  5.  * xo, yo - the origin of the drawing
  6.  * wcurve - the curve width
  7.  * htab - tab height
  8.  * strokegray - gray used to stroke the curve
  9.  * fillgray - gray used to fill the curve
  10.  */
  11. defineps Misc_drawLeftTabBezier(int xo, yo, wcurve, htab; float strokegray,
  12.     fillgray)
  13.  
  14.     /leftCurve {
  15.         xo yo moveto
  16.     
  17.         % x0 y0      y0 x0    y1 x1 x1         ...x1   ...x2 y2 y2
  18.         currentpoint exch wcurve 2 div add dup 3 1 roll yo htab sub dup
  19.             % ...y2 x3  ...x3 y3   
  20.             xo wcurve add exch curveto
  21.     } bind def
  22.  
  23.     % Draw and fill bezier curve.
  24.     newpath
  25.     leftCurve
  26.     0 htab rlineto
  27.     closepath
  28.     fillgray setgray fill
  29.  
  30.     % Draw and stroke bezier curve.
  31.     leftCurve
  32.     strokegray setgray stroke
  33. endps
  34.  
  35. /*
  36.  * Draws the end (right) edge of the tab.
  37.  */
  38. defineps Misc_drawRightTabBezier(int xo, yo, wcurve, htab; float strokegray,
  39.     fillgray)
  40.  
  41.     /wbez wcurve 2 div def
  42.     /rightCurve {
  43.         xo yo htab sub moveto
  44.  
  45.         % x0 y0      y1 x1 x1     x1 y1 x1 x1    ...x1 x1 y2 y2  ...x2 y2 y2 x2
  46.         currentpoint exch wbez add dup 3 1 roll dup yo dup 3 1 roll exch
  47.             % ...y2 x3  ...x3 y3
  48.             wbez add exch curveto
  49.     } bind def
  50.  
  51.     % Draw and fill bezier curve.
  52.     newpath
  53.     rightCurve
  54.     wcurve neg 0 rlineto
  55.     closepath
  56.     fillgray setgray fill
  57.  
  58.     % Draw and stroke bezier curve.
  59.     rightCurve
  60.     currentpoint    % Leave current point on stack.
  61.     strokegray setgray stroke
  62.  
  63.     % Blend end of curve with abutting line.  Some sort of rounding error (?)
  64.     % requires y adjustment of 1 unit.
  65.     1 sub moveto
  66.     -2 0 rlineto
  67.     0.5 setgray stroke
  68.  
  69.     % Blend start of curve with abutting line.
  70.     xo yo htab sub moveto
  71.     1 0 rlineto
  72.     fillgray setgray stroke
  73. endps
  74.